//
//  RTJProductController.m
//  RuiTaiJinProject
//
//  Created by jayson on 2018/12/3.
//  Copyright © 2018年 leewei. All rights reserved.
//

#import "RTJProductController.h"
#import "RTJBinDetailsCell.h"
#import "ZXCheckPictureViewController.h"
#import "WSLPictureBrowseView.h"


@interface RTJProductController ()<ChcekImgViewDelegate,UIScrollViewDelegate>

@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (nonatomic,strong)WSLPictureBrowseView * browseView;
@end

@implementation RTJProductController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.tableView.tableFooterView=[UIView new];
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.tableView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;
    self.tableView.estimatedRowHeight=300;
    [self.tableView reloadData];
    
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return _data ? 1 : 0;
    
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return UITableViewAutomaticDimension;
    
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    static NSString * ID = @"RTJBinDetailsCell";
    
    RTJBinDetailsCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    
    if (!cell) {
        
        cell = [[NSBundle mainBundle] loadNibNamed:@"RTJBinDetailsCell" owner:self options:nil][0];
    }
    cell.data = _data;
    cell.delegate = self;
    cell.selectionStyle=UITableViewCellSelectionStyleNone;
    return  cell;
    
}

-(void)didImagesViewAction:(NSMutableArray *)pictureStrArr index:(NSIndexPath *)index{
    
        if (pictureStrArr.count > 0) {
            
//            WSLPictureBrowseView * browseView = [[WSLPictureBrowseView alloc] initWithFrame:CGRectMake(0, 0, screenW, screenH)];
//            browseView.backgroundColor = [UIColor blackColor];
//            browseView.urlArray = pictureStrArr;
//            browseView.viewController = self;
//            _browseView = browseView;
//            [[UIApplication sharedApplication].keyWindow addSubview:browseView];
//
//            UITapGestureRecognizer *gesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(commentTableViewTouchInSide)];
//                gesture.numberOfTapsRequired = 1;
//                [self.browseView addGestureRecognizer:gesture];

            
            NSString *tagStr = [NSString stringWithFormat:@"%ld",index.row+1];

            [ZXCheckPictureViewController showSuperController:self withPicArray:pictureStrArr withDefaultIndex:tagStr.integerValue];
        }
    
}

-(void)commentTableViewTouchInSide{
    
    [self.browseView removeFromSuperview];
    
}

@end
